package TCPTest06;

import java.io.*;
import java.net.Socket;

public class Client {

    public static void main(String[] args) throws IOException {

        //创建socket对象
        Socket socket = new Socket("127.0.0.1",10000);
        //获取输出流
        OutputStream outputStream = socket.getOutputStream();
        //输出缓冲流
        BufferedOutputStream bos = new BufferedOutputStream(outputStream);
        // 输入缓冲流
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("E:\\webP\\client\\1.txt"));
        //读取文件，并通过tcp输出
        int len;
        byte[] bytes = new byte[1024];
        while ((len = bis.read(bytes))!= -1){
            bos.write(bytes,0,len);
        }
        bos.flush();
        socket.shutdownOutput();

        //关闭资源
        socket.close();
        bos.close();
    }
}
